package itheima.zuoye.Test1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class test {
    public static void main(String[] args) {

        List<Student> students = new ArrayList<>();
        students.add(new Student("小李", 18, 1.80));
        students.add(new Student("小王", 17, 1.70));
        students.add(new Student("小张", 18, 1.90));
        students.add(new Student("小胡", 17, 1.80));
//1.需求1：对一组学生数据按照年纪进行升序排序，如果年纪一致按照身高进行降序排序

        Collections.sort(students, (o1, o2) -> {
            if(o1.getAge() == o2.getAge()){
                 return Double.compare(o2.getHeight(), o1.getHeight());
            }else{
                return o1.getAge() - o2.getAge();
            }
        });

        students.forEach(System.out::println);




    }

}
